<template>
  <el-container>
    <el-header style="border-bottom: 1px solid rgba(255,255,255,0.12)">
      <p style="font-family: MicrosoftYaHei;font-size: 16px;color: #7DDAFF;">疑似违规</p>
    </el-header>
    <el-main>
      <el-row class="btn-group">
        <el-button class="btn" @click="handleImport"><span>导入</span><i class="el-icon-upload2"></i>
        </el-button>
        <el-button class="btn" @click="handleDownloadParkingMag"><span>导出</span><i class="el-icon-download"></i>
        </el-button>
        <el-button class="four-btn" @click="handleDownloadParkingMagExcel"><span>下载模板</span><i
          class="el-icon-download"></i>
        </el-button>
      </el-row>
      <el-table :data="dataList" v-loading="listLoading" element-loading-text="给我一点时间"
                element-loading-background="rgba(0, 0, 0, .3)"
                height="500"
                :row-class-name="tableRowClassName"
                style="width: 100%;padding-top: 0px;background-color: #1B4685"
                ref="parkingMagTable" @selection-change="handleSelectChangeParkingMag">
        <el-table-column fixed type="selection" width="55"></el-table-column>
        <el-table-column fixed sortable align="center" label="投诉对象" width="150" prop="complaints_obj">
          <template slot-scope="scope">
            <span>{{scope.row.complaints_obj}}</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="投诉类型" width="150" sortable prop="complaints_type">
          <template slot-scope="scope">
            <span>{{scope.row.complaints_type}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="投诉数量" width="200" sortable prop="complaints_count">
          <template slot-scope="scope">
            <span>{{scope.row.complaints_count}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="起始时间" width="200" sortable prop="start_time">
          <template slot-scope="scope">
            <span>{{scope.row.start_time}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="终止时间" width="200" sortable prop="end_time">
          <template slot-scope="scope">
            <span>{{scope.row.end_time}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="处理状态" width="200" sortable prop="handle_status">
          <template slot-scope="scope">
            <span>{{scope.row.handle_status}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="处理结果" width="200" sortable prop="handle_result">
          <template slot-scope="scope">
            <span>{{scope.row.handle_result}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="处理人" width="200" sortable prop="handle_people">
          <template slot-scope="scope">
            <span>{{scope.row.handle_people}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="完成时间" width="200" sortable prop="finish_time">
          <template slot-scope="scope">
            <span>{{scope.row.finish_time}}</span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" width="100" label="操作">
          <template slot-scope="scope">
            <el-dropdown trigger="click" @command="handleCommand">
              <el-button class="btn-drop-down" @click="selectRow(scope.row)">
                <i class="el-icon-arrow-down"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="detail">详情</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
    <el-footer>
      <el-pagination style="margin-top: 16px" background @size-change="handleSizeChangeParkingMag"
                     @current-change="handleCurrentChangeParkingMag"
                     :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-footer>
    <suggestion-detail-dailog  :dialogStatusParkMag="dialogStatusParkMag"
                               :dialogVisible.sync="dialogCreateVisible" :tempParkMag="tempParkMag"></suggestion-detail-dailog>
    <track-upload-excel :uploadVisible.sync="dialogUploadVisible"></track-upload-excel>
    <!--<el-dialog :title="'导入'" :visible.sync="dialogUploadVisible" center>
      <el-upload
        class="upload-demo" ref="upload" action="https://jsonplaceholder.typicode.com/posts/"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :file-list="fileList"
        :auto-upload="false">
        <el-button slot="trigger" type="primary">选取文件</el-button>
        <el-button style="margin-left: 20px;" type="success" @click="submitUpload">上传到服务器</el-button>
        <div slot="tip" class="el-upload__tip">只能上传XXX文件，且不超过500kb</div>
      </el-upload>
    </el-dialog>-->
  </el-container>

</template>

<script>
  /* eslint-disable */
  import suggestionDetailDailog from "./suggestionDetailDailog";
  // import {createParkMag, updateParkMag, deleteParkMag} from "../../../api/parkingResource/parkingMag";
  import ElContainer from "element-ui/packages/container/src/main";
  import ElHeader from "element-ui/packages/header/src/main";
  import ElMain from "element-ui/packages/main/src/main";
  import ElFooter from "element-ui/packages/footer/src/main";
  import TrackUploadExcel from "../../comprehensive/compreChild/trackUploadExcel";

  export default {
    components: {
      TrackUploadExcel,
      ElFooter,
      ElMain,
      ElHeader,
      ElContainer,
      suggestionDetailDailog,
    },
    name: "suggestion-table",
    props: ['searchList', 'listLoadingParkingMag'],
    watch: {
      searchList(val) {
        this.dataList = val.list
        this.total = val.count
      },
      listLoadingParkingMag(val) {
        this.listLoading = val
      }
    },
    data() {
      return {

        listLoading: false,
        downloadLoading: false,
        dialogCreateVisible: false,
        dialogUploadVisible: false,
        dialogStatusParkMag: '',
        dataList: [],
        selectList: [],
        fileList: [],
        total: 10,
        tempParkMag: {
          complaints_obj: '',
          complaints_type: '',
          complaints_count: '',
          start_time:'',
          end_time:'',
          handle_status: '',
          handle_result:'',
          handle_people:'',
          finish_time:'',
          complaints_people:'',
          complaints_phone:'',
          complaints_channel:'',
          complaints_time:'',
          complaints_text:''
        },
        listQuery: {
          page: 1,
          limit: 20
        }
      }
    },
    methods: {
      handleUpdateParkingMag() {
        this.dialogStatusParkMag = 'detail'
        this.dialogCreateVisible = true
      },
      handleDeleteParkingMag() {
        this.deleteDataParkMag(this.selectList)
      },
      handleDownloadParkingMag() {
        if (this.selectList.length) {

        } else {
          this.$message({
            showClose: true,
            message: '至少选择一条',
            duration: 2000,
            type: 'warning'
          })
        }
        this.downloadLoading = true
      },
      handleDownloadParkingMagExcel() {
      },
      handleImport() {
        this.dialogUploadVisible = true
      },
      handleSelectChangeParkingMag(val) {
        this.selectList = val
      },
      handleSizeChangeParkingMag(val) {
        this.listQuery.limit = val
        this.$emit("handleSizeChangeParkingMag", val)
      },
      handleCurrentChangeParkingMag(val) {
        this.listQuery.page = val
        this.$emit("handleCurrentChangeParkingMag", val)
      },
      //   createDataParkMag(val) {
      //     createParkMag(val).then(res => {
      //       this.dataList.unshift(val)
      //       this.dialogCreateVisible = false
      //       this.$notify({
      //         title: '成功',
      //         message: '创建成功',
      //         type: 'success',
      //         duration: 2000
      //       })
      //     })
      //   },
      //   deleteDataParkMag(val) {
      //     if (val.length) {
      //       this.$confirm('此操作将永久删除选中的记录,是否继续?', '提示', {
      //         confirmButtonText: '确定',
      //         cancelButtonText: '取消',
      //         type: 'warning'
      //       }).then(() => {
      //         deleteParkMag(val).then(res => {
      //           for (const v of val) {
      //             let indexOf = this.dataList.indexOf(v);
      //             this.dataList.splice(indexOf, 1)
      //           }
      //           this.$message({
      //             showClose: true,
      //             message: '删除成功',
      //             type: 'success',
      //             duration: 2000
      //           });
      //         })
      //       })
      //     } else {
      //       this.$message({
      //         showClose: true,
      //         message: '请选择至少一条删除',
      //         type: 'warning',
      //         duration: 2000
      //       });
      //     }
      //   },
      //   updateDataParkMag(val) {
      //     updateParkMag(val).then(res => {
      //       this.dialogCreateVisible = false
      //       for (const v of this.dataList) {
      //         if (v.park_no === this.tempParkMag.park_no) {
      //           const index = this.dataList.indexOf(v)
      //           this.dataList.splice(index, 1, val)
      //           break
      //         }
      //       }
      //       this.$notify({
      //         title: '成功',
      //         message: '更新成功',
      //         type: 'success',
      //         duration: 2000
      //       })
      //     })
      //   },
      submitUpload() {
        this.$refs.upload.submit();
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleCommand(val) {
        if(val=="detail"){
          this.handleUpdateParkingMag()
        }
      },
      selectRow(val) {
        this.tempParkMag =Object.assign({},val) // copy obj
      },
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex % 2 === 0) {
          return 'one-row';
        }
        return '';
      }
    }
  }
</script>

<style scoped>
  .btn-group > .el-button span {
    display: none;
  }

  .btn-group > .el-button:hover {
    background-color: #409EFF;
  }

  .btn-group > .el-button:hover span {
    display: block;
  }

  .btn-group > .el-button:hover i {
    display: none;
  }
</style>
